Flash memory is typically written in units of blocks. In a given block, there are several pages of data. Over time, some of those pages may be marked as invalid, such as when an updated version of the data in a page is written to another block. Accordingly, at any given time, a given block may contain several pages of invalid data. Also, because flash memory is written in units of blocks, when a storage module want to write a page to an existing block, the storage module reads the pages previously-stored in the existing block and then writes those pages, as well as the new page, to another block in memory. Because some of the previously-stored pages may no longer be valid, the storage module determines which pages are still valid and only writes the valid pages to the new block. This process can be time consuming and can reduce the performance of the system.
To improve performance, a storage module can implement a management process known as garbage collection. With garbage collection, the storage module's controller uses its idle time to consolidate blocks of flash memory before the host needs to write new data. This improves system performance because the process of determining which pages are valid and then moving those pages occurs when the storage module is idle rather than when a user is awaiting a write operation. In theory, if the storage module controller were to collect all of the spare blocks before it was necessary, new data can be written from a host without having to move any data, resulting in optimum performance.
Several triggers can be used to start a garbage collection operation. For example, some storage modules use a fixed a-priori design for performing garbage collection. Other storage modules, such as solid state drives (SSD), use arbitrary benchmarks to trigger garbage collection. For example, some SSDs wait for a predetermined time of inactivity before starting a garbage collection operation. These predetermined times are based on the assumption that SSDs often have relatively long periods of inactivity (e.g., few minutes) between heavy periods of use. However, because these benchmarks are predetermined, it is possible that the storage module can receive an incoming command (e.g., from an external host) when a garbage collection operation is in process. In such a situation, the garbage collection operation is typically interrupted in order to execute the incoming command with minimal degradation to the user experience. However, the fact that the storage module is occupied with system maintenance while an incoming command is received is, by itself, a cause for additional latency and degradation in the user experience.